﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: AutoNumberItems.cs
//
//  Description: List of autonumber properties of a persistent.
// 
//--------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Collections.Generic;

namespace Chili.Opf3.Query
{
	/// <summary>
	/// Contains the attributes of the persistent object and of the properties marked as autonumbers.
	/// </summary>
	/// <remarks>
	/// This class contains the attributes of the persistent object and of the properties marked as autonumbers. 
	/// It is required by some storages to do the autonumber processing. The class contains all items
	/// to do the autonumber processing, such as all <see cref="Opf3.FieldAttribute">FieldAttributes</see>
	/// and the <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent class.
	/// </remarks>
	public sealed class AutoNumberItems : List<AutoNumberItem>
	{
		private PersistentAttribute _persistentAttribute;

		/// <summary>
		/// Creates a new instance of the <see cref="AutoNumberItems">AutoNumberItems Class</see>.
		/// </summary>
		/// <param name="persistentAttribute">The <see cref="Opf3.PersistentAttribute">PersistentAttribute</see>
		/// of the persistent object that is inserted.</param>
		/// <exception cref="ArgumentNullException">PersistentAttribute is null.</exception>
		public AutoNumberItems(PersistentAttribute persistentAttribute)
		{
			if (persistentAttribute == null)
				throw new ArgumentNullException("persistentAttribute");
			_persistentAttribute = persistentAttribute;
		}

		/// <summary>
		/// Returns the <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent
		/// object that is inserted.
		/// </summary>
		/// <value>The <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent
		/// object that is inserted.</value>
		public PersistentAttribute PersistentAttribute
		{
			get { return _persistentAttribute; }
		}
	}
}
